package com.venta.autopartes.utils;

import java.util.Map;

import com.venta.autopartes.user.UserPrivilage;

public final class SessionValidator {
	public static final String INVALID_SESSION="INVALID_SESSION";
	public static final String INVALID_ACTION="INVALID_ACTION";
	
	public static boolean isValidSession(Map<String,Object> session){
		boolean valid=false;
		
		DataCatalog dataCatalog=(DataCatalog)session.get(Constants.DATA_CATALOG);
		
		if(dataCatalog!=null && session.get(Constants.USER_LOGGED)!=null){
			String sessionType=(String)session.get(Constants.SESSION_TYPE);
			for(UserPrivilage userPrivilage: dataCatalog.getUserPrivilageList()){
				if(userPrivilage.getUserPrivilage().equalsIgnoreCase(sessionType)){
					valid=true;
				}
				
			}
		}
		
		return valid;
	}
}
